<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Update license API | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'update-license.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/update-license.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/update-license.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/update-license.html" rel="nofollow" target="_blank">../en/update-license.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="rest-apis.html">REST APIs</a></span>
»
<span class="breadcrumb-link"><a href="licensing-apis.html">Licensing APIs</a></span>
»
<span class="breadcrumb-node">Update license API</span>
</div>
<div class="navheader">
<span class="prev">
<a href="start-basic.html">« Start basic API</a>
</span>
<span class="next">
<a href="ml-apis.html">Machine learning anomaly detection APIs »</a>
</span>
</div>
<div class="section xpack">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="update-license"></a>Update license API<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/licensing/update-license.asciidoc">edit</a><a class="xpack_tag" href="https://www.elastic.co/subscriptions"></a>
</h2>
</div></div></div>

<p>Updates the license for your Elasticsearch cluster.</p>
<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="update-license-api-request"></a>Request<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/licensing/update-license.asciidoc">edit</a>
</h3>
</div></div></div>
<p><code class="literal">PUT _license</code></p>
<p><code class="literal">POST _license</code></p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="update-license-api-prereqs"></a>Prerequisites<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/licensing/update-license.asciidoc">edit</a>
</h3>
</div></div></div>
<p>If Elasticsearch security features are enabled, you need <code class="literal">manage</code> cluster privileges to
install the license.</p>
<p>If Elasticsearch security features are enabled and you are installing a gold or platinum
license, you must enable TLS on the transport networking layer before you
install the license. See <a class="xref" href="configuring-tls.html" title="Encrypting communications in Elasticsearch">Encrypting communications in Elasticsearch</a>.</p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="update-license-api-desc"></a>Description<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/licensing/update-license.asciidoc">edit</a>
</h3>
</div></div></div>
<p>You can update your license at runtime without shutting down your nodes. License
updates take effect immediately. If the license you are installing does not
support all of the features that were available with your previous license,
however, you are notified in the response. You must then re-submit the API
request with the <code class="literal">acknowledge</code> parameter set to <code class="literal">true</code>.</p>
<p>For more information about the different types of licenses, see
<a href="https://www.elastic.co/subscriptions" class="ulink" target="_top">https://www.elastic.co/subscriptions</a>.</p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="update-license-api-query-params"></a>Query parameters<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/licensing/update-license.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">acknowledge</code>
</span>
</dt>
<dd>
(Optional, boolean)
Specifies whether you acknowledge the license changes. The default
value is <code class="literal">false</code>.
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="update-license-api-request-body"></a>Request body<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/licensing/update-license.asciidoc">edit</a>
</h3>
</div></div></div>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<code class="literal">licenses</code>
</span>
</dt>
<dd>
(Required, array)
A sequence of one or more JSON documents containing the license information.
</dd>
</dl>
</div>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="update-license-api-example"></a>Examples<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/licensing/update-license.asciidoc">edit</a>
</h3>
</div></div></div>
<p>The following example updates to a basic license:</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">PUT _license
{
  "licenses": [
    {
      "uid":"893361dc-9749-4997-93cb-802e3d7fa4xx",
      "type":"basic",
      "issue_date_in_millis":1411948800000,
      "expiry_date_in_millis":1914278399999,
      "max_nodes":1,
      "issued_to":"issuedTo",
      "issuer":"issuer",
      "signature":"xx"
    }
    ]
}</pre>
</div>
<div class="console_widget" data-snippet="snippets/1794.console"></div>
<div class="note admon">
<div class="icon"></div>
<div class="admon_content">
<p>These values are invalid; you must substitute the appropriate content
from your license file.</p>
</div>
</div>
<p>You can also install your license file using a <code class="literal">curl</code> command. Be sure to add
<code class="literal">@</code> before the license file path to instruct curl to treat it as an input file.</p>
<div class="pre_wrapper lang-shell">
<pre class="programlisting prettyprint lang-shell">curl -XPUT -u &lt;user&gt; 'http://&lt;host&gt;:&lt;port&gt;/_license' -H "Content-Type: application/json" -d @license.json</pre>
</div>
<p>On Windows, use the following command:</p>
<div class="pre_wrapper lang-shell">
<pre class="programlisting prettyprint lang-shell">Invoke-WebRequest -uri http://&lt;host&gt;:&lt;port&gt;/_license -Credential elastic -Method Put -ContentType "application/json" -InFile .\license.json</pre>
</div>
<p>In these examples,</p>
<div class="ulist itemizedlist">
<ul class="itemizedlist">
<li class="listitem">
<code class="literal">&lt;user&gt;</code> is a user ID with the appropriate authority.
</li>
<li class="listitem">
<code class="literal">&lt;host&gt;</code> is the hostname of any node in the Elasticsearch cluster  (<code class="literal">localhost</code> if
executing locally)
</li>
<li class="listitem">
<code class="literal">&lt;port&gt;</code> is the http port (defaults to <code class="literal">9200</code>)
</li>
<li class="listitem">
<code class="literal">license.json</code> is the license JSON file
</li>
</ul>
</div>
<div class="note admon">
<div class="icon"></div>
<div class="admon_content">
<p>If your Elasticsearch node has SSL enabled on the HTTP interface, you must
  start your URL with <code class="literal">https://</code></p>
</div>
</div>
<p>If you previously had a license with more features than the basic license, you
receive the following response:</p>
<div class="pre_wrapper lang-js">
<pre class="programlisting prettyprint lang-js">  {
  "acknowledged": false,
  "license_status": "valid",
  "acknowledge": {
    "message": """This license update requires acknowledgement. To acknowledge the license, please read the following messages and update the license again, this time with the "acknowledge=true" parameter:""",
    "watcher": [
      "Watcher will be disabled"
    ],
    "logstash": [
      "Logstash will no longer poll for centrally-managed pipelines"
    ],
    "security": [
      "The following X-Pack security functionality will be disabled: ..." ]
    }
}</pre>
</div>
<p>To complete the update, you must re-submit the API request and set the
<code class="literal">acknowledge</code> parameter to <code class="literal">true</code>. For example:</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">PUT _license?acknowledge=true
{
  "licenses": [
    {
      "uid":"893361dc-9749-4997-93cb-802e3d7fa4xx",
      "type":"basic",
      "issue_date_in_millis":1411948800000,
      "expiry_date_in_millis":1914278399999,
      "max_nodes":1,
      "issued_to":"issuedTo",
      "issuer":"issuer",
      "signature":"xx"
    }
    ]
}</pre>
</div>
<div class="console_widget" data-snippet="snippets/1795.console"></div>
<p>Alternatively:</p>
<div class="pre_wrapper lang-sh">
<pre class="programlisting prettyprint lang-sh">curl -XPUT -u elastic 'http://&lt;host&gt;:&lt;port&gt;/_license?acknowledge=true' -H "Content-Type: application/json" -d @license.json</pre>
</div>
<p>For more information about the features that are disabled when your license
expires, see
<a href="https://www.elastic.co/guide/en/kibana/7.7/managing-licenses.html#license-expiration" class="ulink" target="_top">License expiration</a>.</p>
</div>

</div>
<div class="navfooter">
<span class="prev">
<a href="start-basic.html">« Start basic API</a>
</span>
<span class="next">
<a href="ml-apis.html">Machine learning anomaly detection APIs »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>